﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CodeFirst.Migrations
{
    public partial class init001 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "sys_Account",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    AccountNo = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: false),
                    Pwd = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    PwdKey = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Tel = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true),
                    EnableState = table.Column<int>(type: "int", nullable: false),
                    IsSysTem = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_Account", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_AccountRole",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    AccountId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    RoleId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_AccountRole", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_ApiLog",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    PushUrl = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
                    PushContent = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ResponseContent = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
                    RequestTime = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    State = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateUserCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_ApiLog", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_codecreatetable",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_codecreatetable", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_ErrorLog",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Message = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
                    StackTrace = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Ip = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    RequestPath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateUserCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_ErrorLog", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_LoginLog",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    AccountNo = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: true),
                    Pwd = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    LoginState = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    LoginIP = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    LoginAction = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateUserCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_LoginLog", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_Menu",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MenuName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    Icon = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    LinkUrl = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    ParentId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Level = table.Column<int>(type: "int", maxLength: 2, nullable: false),
                    EnableState = table.Column<int>(type: "int", nullable: false),
                    Sort = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_Menu", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_MenuAction",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MenuId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Code = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_MenuAction", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_Role",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    RoleName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Sort = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_Role", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_RoleMenu",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MenuId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    RoleId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_RoleMenu", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_RoleMenuAction",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MenuId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    RooleId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    MenuActionId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_RoleMenuAction", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_SysConfig",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Type = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Key = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Value = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_SysConfig", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "sys_WXUser",
                columns: table => new
                {
                    Id = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    OpenId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Unionid = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    NickName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    Gender = table.Column<int>(type: "int", maxLength: 20, nullable: false),
                    AvatarUrl = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    PhoneNumber = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    Country = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Province = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    City = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UserLever = table.Column<int>(type: "int", nullable: true),
                    EnableState = table.Column<int>(type: "int", maxLength: 2, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    DeleteTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    UpdateUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    DeleteUser = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sys_WXUser", x => x.Id);
                });

            migrationBuilder.InsertData(
                table: "sys_Account",
                columns: new[] { "Id", "AccountNo", "CreateTime", "CreateUser", "DeleteTime", "DeleteUser", "EnableState", "IsDelete", "IsSysTem", "Name", "Pwd", "PwdKey", "Remark", "Tel", "UpdateTime", "UpdateUser" },
                values: new object[] { "xitongguanliyuan", "admin", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, false, 1, "系统管理员", "vGjHvVtojoSOOyhqZCCnFQ==", "", "系统管理员", "", null, "" });

            migrationBuilder.InsertData(
                table: "sys_AccountRole",
                columns: new[] { "Id", "AccountId", "CreateTime", "CreateUser", "DeleteTime", "DeleteUser", "IsDelete", "Remark", "RoleId", "UpdateTime", "UpdateUser" },
                values: new object[] { "xitongguanliyuanbindrole", "xitongguanliyuan", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", false, "系统管理员", "xitongguanliyuanrole", null, "" });

            migrationBuilder.InsertData(
                table: "sys_Menu",
                columns: new[] { "Id", "Code", "CreateTime", "CreateUser", "DeleteTime", "DeleteUser", "EnableState", "Icon", "IsDelete", "Level", "LinkUrl", "MenuName", "ParentId", "Remark", "Sort", "UpdateTime", "UpdateUser" },
                values: new object[,]
                {
                    { "caidanguanli", "system.menu", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-menu", false, 2, "/menu", "菜单管理", "xitonggongju", "系统初始数据", 1, null, "" },
                    { "daimashengchenggongju", "system.codecreate", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-s-grid", false, 2, "/codecreate", "代码生成工具", "xitonggongju", "系统初始数据", 8, null, "" },
                    { "denglurizhi", "system.loginlog", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-s-grid", false, 2, "/loginlog", "登录日志", "xitonggongju", "系统初始数据", 5, null, "" },
                    { "disanfangjiekourizhi", "system.apilog", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-s-grid", false, 2, "/apilog", "第三方接口日志", "xitonggongju", "系统初始数据", 7, null, "" },
                    { "juesegaunli", "system.role", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-s-check", false, 2, "/role", "角色管理", "xitonggongju", "系统初始数据", 3, null, "" },
                    { "xitongcuowurizhi", "system.errorlog", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-s-grid", false, 2, "/errorlog", "系统错误日志", "xitonggongju", "系统初始数据", 6, null, "" },
                    { "xitonggongju", "system", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "系统设置.png", false, 1, "", "系统工具", "", "系统初始数据", 99, null, "" },
                    { "zhanghaoguanlli", "system.account", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", 1, "el-icon-s-custom", false, 2, "/account", "账号管理", "xitonggongju", "系统初始数据", 2, null, "" }
                });

            migrationBuilder.InsertData(
                table: "sys_Role",
                columns: new[] { "Id", "CreateTime", "CreateUser", "DeleteTime", "DeleteUser", "IsDelete", "Remark", "RoleName", "Sort", "UpdateTime", "UpdateUser" },
                values: new object[] { "xitongguanliyuanrole", new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "", null, "", false, "系统管理员", "系统管理员", 1, null, "" });

            migrationBuilder.CreateIndex(
                name: "IX_sys_Account_AccountNo",
                table: "sys_Account",
                column: "AccountNo");

            migrationBuilder.CreateIndex(
                name: "IX_sys_ApiLog_CreateUserName",
                table: "sys_ApiLog",
                column: "CreateUserName");

            migrationBuilder.CreateIndex(
                name: "IX_sys_ErrorLog_CreateUserName",
                table: "sys_ErrorLog",
                column: "CreateUserName");

            migrationBuilder.CreateIndex(
                name: "IX_sys_LoginLog_CreateUserName",
                table: "sys_LoginLog",
                column: "CreateUserName");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "sys_Account");

            migrationBuilder.DropTable(
                name: "sys_AccountRole");

            migrationBuilder.DropTable(
                name: "sys_ApiLog");

            migrationBuilder.DropTable(
                name: "sys_codecreatetable");

            migrationBuilder.DropTable(
                name: "sys_ErrorLog");

            migrationBuilder.DropTable(
                name: "sys_LoginLog");

            migrationBuilder.DropTable(
                name: "sys_Menu");

            migrationBuilder.DropTable(
                name: "sys_MenuAction");

            migrationBuilder.DropTable(
                name: "sys_Role");

            migrationBuilder.DropTable(
                name: "sys_RoleMenu");

            migrationBuilder.DropTable(
                name: "sys_RoleMenuAction");

            migrationBuilder.DropTable(
                name: "sys_SysConfig");

            migrationBuilder.DropTable(
                name: "sys_WXUser");
        }
    }
}
